﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Distribution.Dto
@using FwProject.Core.Distribution
@model IPagedList<DistributionTypeNumberReportDto>
@{
    Layout = null;
    int count = 0;
    int SumDistributioncount = 0;
    int SumDistributionNumbercount = 0;

    int SumRecoveryBycount = 0;
    int SumRecoveryNumbercount = 0;
    int SumExchangegoodscount = 0;
    int SumExchangegoodsNumbercount = 0;
    int SumDamagecount = 0;
    int SumGivecount = 0;
    int SumGiveNumbercount = 0;
    int SumBackboxcount = 0;
    int SumBacknumbercount = 0;
    decimal SumPrice = 0;
    int x = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            x = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
    List<DistributionTypeNumberReportDto> list = ViewBag.DistributionDetails;
}
<div id="table_print2" style="max-height:600px;overflow-y:scroll;">

    <table class="table table-bordered table-hover table-rowselected">
        <thead>
            <tr>
                <th style="width:45px">序号</th>
                <th>餐厅名称</th>
                <th>货品型号</th>
                <th>单价</th>
                <th>配送箱数</th>
                <th>配送套数</th>
                <th>回收箱数</th>
                <th>回收套数</th>
                <th>换货箱数</th>
                <th>换货套数</th>
                <th>折损套数</th>
                <th>赠送箱数</th>
                <th>赠送套数</th>
                <th>退回箱数</th>
                <th>退回套数</th>
                <th>金额（￥）</th>
                @*<th style="width:200px;">操作</th>*@
            </tr>
        </thead>
        <tbody>
            @if (Model.Count == 0)
            {
                <tr><td class="text-center" colspan="12">暂无信息</td></tr>
            }
            else
            {
                foreach (var item in Model)
                {
                    x++;
                    count = item.TypeNumberModelList.Count;
                    if (count > 0)
                    {
                        SumDistributioncount += item.TypeNumberModelList.Sum(o => o.Distributioncount);
                        SumDistributionNumbercount += item.TypeNumberModelList.Sum(o => o.DistributionNumbercount);
                        SumRecoveryBycount += item.TypeNumberModelList.Sum(o => o.Recoverycount);
                        SumRecoveryNumbercount += item.TypeNumberModelList.Sum(o => o.RecoveryNumbercount);
                        SumExchangegoodscount += item.TypeNumberModelList.Sum(o => o.Exchangegoodscount);
                        SumExchangegoodsNumbercount += item.TypeNumberModelList.Sum(o => o.ExchangegoodsNumbercount);

                        SumDamagecount += item.TypeNumberModelList.Sum(o => o.Damagecount);
                        SumGivecount += item.TypeNumberModelList.Sum(o => o.Givecount);
                        SumGiveNumbercount += item.TypeNumberModelList.Sum(o => o.GiveNumbercount);

                        SumBackboxcount += item.TypeNumberModelList.Sum(o => o.Backboxcount);
                        SumBacknumbercount += item.TypeNumberModelList.Sum(o => o.Backnumbercount);
                        SumPrice += item.TypeNumberModelList.Sum(o => o.Sumprice);

                        for (int i = 0; i < item.TypeNumberModelList.Count; i++)
                        {
                            <tr>
                                @if (i == 0)
                                {
                                    <td rowspan="@count">@x</td>
                                    <td rowspan="@count">@item.RestaurantName</td>
                                    <td>@item.TypeNumberModelList[i].Name</td>
                                    <td>@item.TypeNumberModelList[i].Price</td>
                                    <td>@item.TypeNumberModelList[i].Distributioncount</td>
                                    <td>@item.TypeNumberModelList[i].DistributionNumbercount</td>
                                    <td>@item.TypeNumberModelList[i].Recoverycount</td>
                                    <td>@item.TypeNumberModelList[i].RecoveryNumbercount</td>
                                    <td>@item.TypeNumberModelList[i].Exchangegoodscount</td>
                                    <td>@item.TypeNumberModelList[i].ExchangegoodsNumbercount</td>
                                    <td>@item.TypeNumberModelList[i].Damagecount</td>
                                    <td>@item.TypeNumberModelList[i].Givecount</td>
                                    <td>@item.TypeNumberModelList[i].GiveNumbercount</td>
                                    <td>@item.TypeNumberModelList[i].Backboxcount</td>
                                    <td>@item.TypeNumberModelList[i].Backnumbercount</td>
                                    <td>@item.TypeNumberModelList[i].Sumprice</td>
                                }
                                else
                                {
                                    <td>@item.TypeNumberModelList[i].Name</td>
                                    <td>@item.TypeNumberModelList[i].Price</td>
                                    <td>@item.TypeNumberModelList[i].Distributioncount</td>
                                    <td>@item.TypeNumberModelList[i].DistributionNumbercount</td>
                                    <td>@item.TypeNumberModelList[i].Recoverycount</td>
                                    <td>@item.TypeNumberModelList[i].RecoveryNumbercount</td>
                                    <td>@item.TypeNumberModelList[i].Exchangegoodscount</td>
                                    <td>@item.TypeNumberModelList[i].ExchangegoodsNumbercount</td>
                                    <td>@item.TypeNumberModelList[i].Damagecount</td>
                                    <td>@item.TypeNumberModelList[i].Givecount</td>
                                    <td>@item.TypeNumberModelList[i].GiveNumbercount</td>
                                    <td>@item.TypeNumberModelList[i].Backboxcount</td>
                                    <td>@item.TypeNumberModelList[i].Backnumbercount</td>
                                    <td>@item.TypeNumberModelList[i].Sumprice</td>
                                }
                            </tr>
                        }
                    }

                }
                <tr class="footer" style="background-color:darkgray">
                    <td style="color:red">合计</td>
                    <td colspan="3"></td>
                    <td style="color:red">@list.Sum(o=>o.TypeNumberModelList.Sum(s=>s.Distributioncount))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.DistributionNumbercount))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.Recoverycount))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.RecoveryNumbercount))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.Exchangegoodscount))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.ExchangegoodsNumbercount))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.Damagecount))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.Givecount)))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.GiveNumbercount))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.Backboxcount))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.Backnumbercount))</td>
                    <td style="color:red">@list.Sum(o => o.TypeNumberModelList.Sum(s => s.Sumprice))</td>
                </tr>
            }
        </tbody>
    </table>
</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        @*共 @Model.TotalItemCount 条，@Model.PageSize 条/页 当前第 @Model.PageNumber/@Model.PageCount 页*@
        共 @Model.TotalItemCount 条，
        <select class="form-control" id="pageSize2" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp;条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&RestaurantName=@(Context.Request.Query["RestaurantName"])&DriverName=@(Context.Request.Query["DriverName"])&beginTime2=@(Context.Request.Query["beginTime2"])&endTime2=@(Context.Request.Query["endTime2"])&key=2" />
        @Html.PagedListPager(Model, page => Url.Action("RestaurantDistribution", new { pageIdx = page, size2 = Context.Request.Query["size2"], RestaurantName = Context.Request.Query["RestaurantName"], DriverName = Context.Request.Query["DriverName"], beginTime2 = Context.Request.Query["beginTime2"], endTime2 = Context.Request.Query["endTime2"], key = 2 }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list2", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>




